package cn.maihe.elg.operation.supports.electronicseal.anne.service.impl;

import cn.maihe.elg.operation.config.AnneSignConfig;
import cn.maihe.elg.operation.config.ElgConfig;
import cn.maihe.elg.operation.supports.electronicseal.anne.AnneServiceName;
import cn.maihe.elg.operation.supports.electronicseal.anne.BaseAnneSignService;
import cn.maihe.elg.operation.supports.electronicseal.anne.bean.annesign.base.DictDataRequest;
import cn.maihe.elg.operation.supports.electronicseal.anne.bean.annesign.base.DictDataResponse;
import cn.maihe.elg.operation.supports.electronicseal.anne.utils.annesign.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * @Description 数据字典
 * @Author WJH
 * @Date 2021/08/13
 */
@Slf4j
@Service
public class AnneApiParamService extends BaseAnneSignService<DictDataRequest, DictDataResponse> {


    public AnneApiParamService(AnneSignConfig anneSignConfig, ElgConfig elgConfig) {
        super(anneSignConfig, elgConfig);
    }

    @Override
    protected AnneServiceName serviceName() {
        return AnneServiceName.param_list;
    }

    @PostConstruct
    public void initGetDictData(){
//        this.getDictData();
    }

    public DictDataResponse getDictData() {

        DictDataRequest request = this.buildBaseReq();

        DictDataResponse response = null;
        try {
            response = this.doPost(request);
        } catch (Exception e) {
            log.error("获取安妮数据字典异常:{}", e.getMessage(), e);
            throw new ApiException("获取数据字典异常:" + e.getMessage(), e);
        }
        return response;
    }

    @Override
    public String getSecretKey() {
        return super.getSecretKey();
    }

}
